package com.zjdiepu.www.rest.api.yw;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.Collections;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.core.PageVo;
import com.zjdiepu.www.base.enums.status.AddedStatus1;
import com.zjdiepu.www.base.enums.status.BusiStatus;
import com.zjdiepu.www.base.enums.status.DpStatus;
import com.zjdiepu.www.base.enums.status.LessInformationStatus;
import com.zjdiepu.www.base.enums.status.PhoneStatus;
import com.zjdiepu.www.base.enums.status.RefundStatus;
import com.zjdiepu.www.base.enums.status.TongrongStatus;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.common.consts.SystemConsts;
import com.zjdiepu.www.common.util.CollectionInitUtil;
import com.zjdiepu.www.common.util.DateUtil;
import com.zjdiepu.www.commpent.handler.TokenUserHelper;
import com.zjdiepu.www.commpent.helper.UserMapSalermanHelper;
import com.zjdiepu.www.ibiz.base.IDpBaseDealerInfoService;
import com.zjdiepu.www.ibiz.cache.ICachedDictionaryService;
import com.zjdiepu.www.ibiz.dh.IDhOverdueListService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessBuyerService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessCarService;
import com.zjdiepu.www.ibiz.yw.IYwBusinessLoanService;
import com.zjdiepu.www.ibiz.yw.IYwRestService;
import com.zjdiepu.www.ibiz.zx.IZxCreditQueryService;
import com.zjdiepu.www.ibiz.zx.IZxQueryCreditApplyService;
import com.zjdiepu.www.ibiz.zx.IZxQueryCreditApplySubService;
import com.zjdiepu.www.model.base.dto.DpBaseDealerInfo;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.dh.dto.DhOverdueList;
import com.zjdiepu.www.model.dh.ext.DhOverdueListExt;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.model.yw.dto.YwBusinessBuyer;
import com.zjdiepu.www.model.yw.dto.YwBusinessCar;
import com.zjdiepu.www.model.yw.dto.YwBusinessLoan;
import com.zjdiepu.www.model.yw.ext.YwBusinessBuyerExt;
import com.zjdiepu.www.model.yw.request.YwBusinessBaseRequest;
import com.zjdiepu.www.model.yw.response.BuyerBaseInfo;
import com.zjdiepu.www.model.yw.response.YwBusinessBaseResponse;
import com.zjdiepu.www.model.zx.dto.ZxCreditQuery;
import com.zjdiepu.www.model.zx.dto.ZxQueryCreditApply;
import com.zjdiepu.www.model.zx.dto.ZxQueryCreditApplySub;
import com.zjdiepu.www.model.zx.ext.ZxQueryCreditApplySubExt;
import com.zjdiepu.www.util.CachedEnums;
import com.zjdiepu.www.util.HtmlUtil;

/**
 * 业务信息Controller层<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年04月24日 14时43分<br/>
 * @since 1.0<br/>
 */
@RestController
@RequestMapping(value= "YwRestController", produces="application/json;charset=UTF-8", method=RequestMethod.POST)
@Api(tags = {"业务业务"}, produces="application/json;charset=UTF-8")
public class YwRestController extends BaseController {
	@Resource
    private TokenUserHelper tokenUserHelper;
	@Resource
	private UserMapSalermanHelper userMapSalermanHelper;
    @Resource
    private IYwRestService ywRestService;
    @Resource
    private IYwBusinessBuyerService ywBusinessBuyerService;
    @Resource
    private IZxCreditQueryService zxCreditQueryService;
    @Resource
    private IZxQueryCreditApplyService zxQueryCreditApplyService;
    @Resource
    private IZxQueryCreditApplySubService zxQueryCreditApplySubService;
    @Resource
    private IYwBusinessCarService ywBusinessCarService;
    @Resource
    private IDpBaseDealerInfoService dpBaseDealerInfoService;
    @Resource
    private IDhOverdueListService dhOverdueListService;
    @Resource
    private IYwBusinessLoanService ywBusinessLoanService;
	@Resource
	private ICachedDictionaryService cachedDictionaryService;
	
	/**
     * @author xiongxiaotun <br/>
     * @Title: postSupplementList <br/>
     * @Description: 后补资料列表 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "后补资料列表",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("postSupplementList")
    public ApiResponse postSupplementList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
        SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMinBusiStatus(BusiStatus.CHU_SHEN_DAN_CHU_SHEN_ZHONG.getCode()); //资审一审中之前（包括资审一审中）
	    ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode());//银行已放款（包括）；
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, true, true, false, false, false, true, false, false, true);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
	/**
     * @author xiongxiaotun <br/>
     * @Title: lastThreeYwList <br/>
     * @Description: 最近3条业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "最近3条业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("lastThreeYwList")
    public ApiResponse lastThreeYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, true, false, false, false,false, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
        return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: doingYwList <br/>
     * @Description: 处理中任务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "处理中业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("doingYwList")
    public ApiResponse doingYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, true, true, false, true,false, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
        return ApiResponse.success(page);
    }
    
   /**
     * @author xiongxiaotun <br/>
     * @Title: doneYwList <br/>
     * @Description: 已完成任务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "已完成业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("doneYwList")
    public ApiResponse doneYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMinBusiStatus(BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, true, true, false, false,false, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
        return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: collectYwList <br/>
     * @Description: 收集资料任务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "收集资料业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("collectYwList")
    public ApiResponse collectYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.ZI_SHEN_YI_SHEN_ZHONG.getCode());//资审一审中之前（包括资审一审中）
		ywBusinessBaseRequest.setBusiOrLess(true);
		ywBusinessBaseRequest.addLessInformationStatus(LessInformationStatus.QIAN_ZI_LIAO.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, true, false,false, false, true, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
        return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: contractsYwList <br/>
     * @Description: 签合同业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "签合同业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("contractsYwList")
    public ApiResponse contractsYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.addBusiStatus(BusiStatus.QIAN_SHU_HE_TONG_ZHONG.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, false, true,false, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
        return ApiResponse.success(page);
    }
    
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: fundApplyYwList <br/>
     * @Description: 申请垫资业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "申请垫资业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("fundApplyYwList")
    public ApiResponse fundApplyYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`SUBMIT_TIME` DESC");
		ywBusinessBaseRequest.setWhereSql("AND ((`BUSI_STATUS` >= " + BusiStatus.SHEN_PI_WAN_CHENG.getCode() 
    			+ " AND `CAR_TYPE` = '01') OR (`BUSI_STATUS` >= " + BusiStatus.YI_GUO_HU_SHEN_PI.getCode() 
    			+ " AND `CAR_TYPE` = '02')) "
    			+ " AND (`ADDED_STATUS1` = " + AddedStatus1.AN_JIE_RI_BAO_BIAO_YI_DENG_JI.getCode()
    			+ " OR `ADDED_STATUS1` = " + AddedStatus1.CAI_WU_YI_SHEN_HE_ZHONG.getCode()
    			+ " OR `ADDED_STATUS1` = " + AddedStatus1.YI_TUI_KUAN.getCode() + ")");
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, false, true, false,false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
        return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: loanAbandonYwList <br/>
     * @Description: 客户弃贷业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "客户弃贷业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("loanAbandonYwList")
    public ApiResponse loanAbandonYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.FENG_KONG_ZONG_JIAN_SHEN_HE_ZHONG.getCode()); //风控总监审核中前(包括)
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, false, true,false, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
        return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: transferYwList <br/>
     * @Description: 过户登记业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "过户登记业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("transferYwList")
    public ApiResponse transferYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.addBusiStatus(BusiStatus.GUO_HU_ZHONG.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, false, true,false, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: remitCarYwList <br/>
     * @Description: 新车提车 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "新车提车",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("remitCarYwList")
    public ApiResponse remitCarYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setCarType("01"); //新车
		ywBusinessBaseRequest.addBusiStatus(BusiStatus.SHEN_PI_WAN_CHENG.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, false, true,false, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: registrationYwList <br/>
     * @Description: 上牌登记业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "上牌登记业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("registrationYwList")
    public ApiResponse registrationYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMinBusiStatus(BusiStatus.SHEN_PI_WAN_CHENG.getCode());
		ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, false, true, false,false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
   /**
     * @author xiongxiaotun <br/>
     * @Title: beforeLoanYwList <br/>
     * @Description: 贷前业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "贷前业务",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("beforeLoanYwList")
    public ApiResponse beforeLoanYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.SHEN_PI_WAN_CHENG.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, true, false, false, false,true, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
   /**
     * @author xiongxiaotun <br/>
     * @Title: inLoanYwList <br/>
     * @Description: 贷中业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "贷中业务 ",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({//通道类型
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("inLoanYwList")
    public ApiResponse inLoanYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMinBusiStatus(BusiStatus.GUO_HU_ZHONG.getCode()); //“审批完成”（不包括）之后
		ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.HETONG_CONSTRACT_OK.getCode()); //“银行已放款”之前（不包括）
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, true, false, false, true,false, false, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: afterLoanYwList <br/>
     * @Description: 贷后业务 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "贷后业务 ",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({ //还款状态、当前逾期金额
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("afterLoanYwList")
    public ApiResponse afterLoanYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.addBusiStatus(BusiStatus.YIN_HANG_YI_FANG_KUAN.getCode()); //“银行已放款”的所有业务信息
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, false, true,false, true, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: tongrongYwList <br/>
     * @Description: 可通融列表 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "可通融列表 ",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({ //“初审单初审失败”（包括）--“风控总监审核失败”（包括）
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("tongrongYwList")
    public ApiResponse tongrongYwList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setBusiOrPhone(true);
		ywBusinessBaseRequest.setMinBusiStatus(BusiStatus.CHU_SHEN_DAN_CHU_SHEN_SHI_BAI.getCode());
		ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.FENG_KONG_ZONG_JIAN_SHEN_HE_SHI_BAI.getCode());
		ywBusinessBaseRequest.setPhoneStatuses(CollectionInitUtil.emptyList());
		ywBusinessBaseRequest.addPhoneStatus(PhoneStatus.PHONE_1_FAIL.getCode());
		ywBusinessBaseRequest.addPhoneStatus(PhoneStatus.PHONE_2_FAIL.getCode());
		ywBusinessBaseRequest.addTongrongStatus(TongrongStatus.NOT_TONGRONG.getCode());
		ywBusinessBaseRequest.setMinCreated((int)(DateUtil.truncAndAddDays(new Date(), -29).getTime() / 1000)); //30天以内(包括今天)
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, false, false,false, true, false, false, false, false);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: registrationOrderList <br/>
     * @Description: 登记订单列表 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "登记订单列表 ",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({ //“初审单初审失败”（包括）--“风控总监审核失败”（包括）
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("registrationOrderList")
    public ApiResponse registrationOrderList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.addBusiStatus(BusiStatus.ZI_LIAO_DENG_JI.getCode());
		ywBusinessBaseRequest.addBusiStatus(BusiStatus.TUI_HUI.getCode());
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, false, false, true, true, false, false, false, true, false, false, true);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: submitOrderList <br/>
     * @Description: 登记订单列表 <br/>
     * @param ywBusinessBaseRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "提交订单列表 ",response = YwBusinessBaseResponse.class, httpMethod="POST")
    @ApiImplicitParams({ //“初审单初审失败”（包括）--“风控总监审核失败”（包括）
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping("submitOrderList")
    public ApiResponse submitOrderList(@Validated @RequestBody YwBusinessBaseRequest ywBusinessBaseRequest){
    	SysUser currentUser = tokenUserHelper.getUser();
    	PageVo page = getPage(ywBusinessBaseRequest);
		ywBusinessBaseRequest.setBaseWhere();
		ywBusinessBaseRequest.setSalesmanId(currentUser.getSalersmanId());
		ywBusinessBaseRequest.setOrderSql("`MODIFIED` DESC");
		ywBusinessBaseRequest.setMaxBusiStatus(BusiStatus.ZI_SHEN_YI_SHEN_ZHONG.getCode()); //资审一审中之前（包括资审一审中）
		int records = ywRestService.countByExt(ywBusinessBaseRequest);
		page.setRecords(records);
		if (records > 0) {
			List<YwBusiness> ywBusinesss = ywRestService.selectByExt(ywBusinessBaseRequest);
			List<YwBusinessBaseResponse> ywResponses = mapYwResponse(ywBusinesss, true, false, true, true, true, false, false, false, true, true);
			page.setRows(ywResponses);
		} else {
			page.setRows(CollectionInitUtil.emptyList());
		}
    	return ApiResponse.success(page);
    }
    
//    ============================================辅助方法===========================================
    
    /**
     * 转换属性：展示
     * @param ywBusinesss
     * @return
     */
    private List<YwBusinessBaseResponse> mapYwResponse(List<YwBusiness> ywBusinesss, boolean model, boolean modified, 
    		boolean creditResut, boolean nameCar, boolean channel, 
    		boolean overDue, boolean danbaren, boolean buyer, 
    		boolean comit, boolean creditSubmitDate,boolean... other){
    	if(CollectionUtils.isEmpty(ywBusinesss)) {
    		return CollectionInitUtil.emptyList();
    	}
    	List<YwBusinessBaseResponse> ywResponses = CollectionInitUtil.emptyList();
    	for(YwBusiness ywBusines : ywBusinesss) {
    		YwBusinessBaseResponse ywResponse = mapYwResponse(ywBusines, model, modified, creditResut, nameCar, channel, overDue, danbaren, buyer, comit, creditSubmitDate, other);
    		if(ywResponse != null) {
    			ywResponses.add(ywResponse);
    		}
    	}
    	return ywResponses;
    	
    }
    
    /**
     * 转换属性：展示
     * @param ywBusinesss
     * @return
     */
	private YwBusinessBaseResponse mapYwResponse(YwBusiness ywBusiness,
			boolean model, boolean modified, boolean creditResut,
			boolean nameCar, boolean channel, boolean overDue, 
			boolean danbaren, boolean buyer, boolean comit, boolean creditSubmitDate,boolean... other) {
		if (ywBusiness == null) {
			return null;
		}
		YwBusinessBaseResponse ywResponse = new YwBusinessBaseResponse();
		BeanUtils.copyProperties(ywBusiness, ywResponse);
		//征信申请新建日期
		if(creditSubmitDate) {
			String queryCreditApplyId = ywBusiness.getQueryCreditApplyId();
			if(StringUtils.isNotBlank(queryCreditApplyId)) {
				ZxQueryCreditApply zxQueryCreditApply = zxQueryCreditApplyService.selectById(queryCreditApplyId);
				ywResponse.setCreditApplyDate(DateUtil.dateTo8String3(new Date(zxQueryCreditApply.getCreated() * 1000)));
			}
		}
		
		//是否可以从相册获取图片
		ywResponse.setPhotoAlbum(false);
		String dealerId = ywBusiness.getDealerId();
		if(StringUtils.isNoneBlank(dealerId)) {
			DpBaseDealerInfo dpBaseDealerInfo = dpBaseDealerInfoService.selectById(dealerId);
			if(null != dpBaseDealerInfo) {
				String dealerLevel = dpBaseDealerInfo.getDealerLevel();
				if("S".equals(dealerLevel)) {
					ywResponse.setPhotoAlbum(true);
				}
			}
		}
		
		//提交订单
		if(comit) {
			Integer busiStatus = ywBusiness.getBusiStatus();
			if(busiStatus != null) {
				if(busiStatus < BusiStatus.CHU_SHEN_DAN_CHU_SHEN_ZHONG.getCode()) {
					ywResponse.setComitInitial(true);
					ywResponse.setComitFinal(false);
				} else if(busiStatus < BusiStatus.QIAN_SHU_HE_TONG_ZHONG.getCode()) {
					ywResponse.setComitInitial(false);
					ywResponse.setComitFinal(false);
				} else if(busiStatus == BusiStatus.QIAN_SHU_HE_TONG_ZHONG.getCode()) {
					ywResponse.setComitInitial(false);
					ywResponse.setComitFinal(true);
				} else if(busiStatus > BusiStatus.QIAN_SHU_HE_TONG_ZHONG.getCode()){
					ywResponse.setComitInitial(false);
					ywResponse.setComitFinal(false);
				}
			} else {
				//TODO:没有业务状态，该记录失效
			}
		}
		
		//购车人
		if(buyer) {
			String id = ywBusiness.getId();
			YwBusinessBuyerExt ywBusinessBuyerExt = new YwBusinessBuyerExt();
			ywBusinessBuyerExt.setBusiId(id);
			ywBusinessBuyerExt.setBaseWhere();
			ywBusinessBuyerExt.withOutPage();
			List<YwBusinessBuyer> ywBusinessBuyers = ywBusinessBuyerService.selectByExt(ywBusinessBuyerExt);
			if(CollectionUtils.isNotEmpty(ywBusinessBuyers)) {
				List<BuyerBaseInfo> buyerBaseInfos = CollectionInitUtil.emptyList();
				for(YwBusinessBuyer ywBusinessBuyer : ywBusinessBuyers) {
					boolean completed = ywBusinessBuyer.isCompleted();
					String carManType = ywBusinessBuyer.getCarManType();
					String buyerId = ywBusinessBuyer.getId();
					BuyerBaseInfo buyerBaseInfo= new BuyerBaseInfo(carManType, buyerId, completed);
					buyerBaseInfos.add(buyerBaseInfo);
					if("01".equals(carManType)) {
						ywResponse.setPeiOuId(buyerId);
					} else if("02".equals(carManType)) {
						ywResponse.addDanBaoRenId(buyerId);
					} else if("03".equals(carManType)) {
						ywResponse.setZhujierenId(buyerId);
					}
				}
				Collections.sort(buyerBaseInfos);
				ywResponse.setBuyerBaseInfos(buyerBaseInfos);
			}
		}
		
		if(danbaren) {
			// 查询征信信息
			String creditApplyId = ywBusiness.getQueryCreditApplyId();
			if (StringUtils.isNotBlank(creditApplyId)) {
				ZxQueryCreditApplySubExt zxQueryCreditApplySubExt = new ZxQueryCreditApplySubExt();
				zxQueryCreditApplySubExt.setBaseWhere();
				zxQueryCreditApplySubExt.setQueryCreditApplyId(creditApplyId);
				zxQueryCreditApplySubExt.setRows(6);
				
				List<ZxQueryCreditApplySub> zxQueryCreditApplySubs = zxQueryCreditApplySubService.selectByExt(zxQueryCreditApplySubExt);
				int peiou = 0;
				int danbaoren = 0;
				for (ZxQueryCreditApplySub zxQueryCreditApplySub : zxQueryCreditApplySubs) {
					String creditPeopleType = zxQueryCreditApplySub.getCreditPeopleType();
					if("01".equals(creditPeopleType)) {
						peiou++;
					} else if("02".equals(creditPeopleType)) {
						danbaoren++;
					}
				}
				peiou = peiou > 1 ? 1 : peiou;
				ywResponse.setCountPeiOu(peiou);
				ywResponse.setCountDanBaoRen(danbaoren);
			}
		}
		
		if (model) {
			ywResponse.setNameBusiStatus((String)CachedEnums.getValue(ywBusiness.getBusiStatus(), BusiStatus.class));
		}
		if (modified) {
			ywResponse.setModifiedDate(ywBusiness.getModified() == null ? "-"
					: DateUtil.dateTo12String(new Date(
							ywBusiness.getModified() * 1000L)));
		}
		if (creditResut) {
			ZxCreditQuery zxCreditQuery = zxCreditQueryService
					.selectById(ywBusiness.getCreditQueryId());
			String nameCreditResult = "-";
			String creditResult = "";
			if (zxCreditQuery != null) {
				creditResult = zxCreditQuery.getCreditResult();
				nameCreditResult = cachedDictionaryService.getName(
						creditResult, DataDicType.CREDIT_RESULT);
			}
			ywResponse.setCreditResult(creditResult);
			ywResponse.setNameCreditResult(nameCreditResult);
			ywResponse.setCreditResultMark(HtmlUtil.filterHtml(zxCreditQuery == null ? "-"
					: zxCreditQuery.getCreditResultMark()));
			ZxQueryCreditApply zxQueryCreditApply = zxQueryCreditApplyService
					.selectById(ywBusiness.getQueryCreditApplyId());
			ywResponse
					.setNameQueryCreditApplycreatedDate((zxQueryCreditApply == null || zxQueryCreditApply
							.getCreated() == null) ? "-" : DateUtil
							.dateTo12String(new Date(zxQueryCreditApply
									.getCreated() * 1000L)));
		}
		if (nameCar) {
			YwBusinessCar ywBusinessCar = new YwBusinessCar();
			ywBusinessCar.setDpStatus(DpStatus.NORMAL.getCode());
			ywBusinessCar.setBusiId(ywBusiness.getId());
			ywBusinessCar = ywBusinessCarService
					.selectRefined(ywBusinessCar);
			if (null != ywBusinessCar) {
				ywResponse.setCarFinish(ywBusinessCar.isCompleted());
				ywResponse.setCarId(ywBusinessCar.getId());
				ywResponse.setNameCarModel(ywBusinessCar.getNameCarModel());
			}
		}
		if (channel) {
			ywResponse
					.setNameChannelType(ywBusiness.getChannelType() == null ? "-"
							: cachedDictionaryService.getName(
									ywBusiness.getChannelType(),
									DataDicType.CHANNEL_TYPE));
		}
		//超期
		if (overDue) {
			DhOverdueListExt dhOverdueListExt = new DhOverdueListExt();
			dhOverdueListExt.setBaseWhere();
			dhOverdueListExt.setBusiId(ywBusiness.getId());
			dhOverdueListExt.setOrderSql("`DATE_OVERDUE` DESC");
			dhOverdueListExt.setRows(1);
			List<DhOverdueList> dhOverdueLists = dhOverdueListService
					.selectByExt(dhOverdueListExt);
			if (CollectionUtils.isNotEmpty(dhOverdueLists)) {
				DhOverdueList dhOverdueList = dhOverdueLists.get(0);
				ywResponse.setNameRefundStatus((String) CachedEnums.getValue(
						ywBusiness.getRefundStatus(), RefundStatus.class));
				ywResponse.setAmountRemainder(dhOverdueList
						.getAmountRemainder());
			}
		}
		
		//车贷信息
		if(other != null && other.length > 0 && other[0]) {
			YwBusinessLoan ywBusinessLoan = new YwBusinessLoan();
			ywBusinessLoan.setBusiId(ywBusiness.getId());
			ywBusinessLoan.setDpStatus(DpStatus.NORMAL.getCode());
			ywBusinessLoan = ywBusinessLoanService.selectRefined(ywBusinessLoan);
			if(null != ywBusinessLoan) {
				ywResponse.setLoanId(ywBusinessLoan.getId());
				ywResponse.setLoanFinish(ywBusinessLoan.isCompleted());
			}
		}
		return ywResponse;
	}
}





